package com.vc.demo.model;

public class RestResult {

    private Integer code = 20001;

    private Boolean success = false;

    private String message;

    private Object data;

    public RestResult() {
    }



    public Boolean getSuccess() {
        return this.success;
    }

    public void setSuccess(Boolean success) {
        this.success = success;
    }

    public Integer getCode() {
        return this.code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return this.message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return this.data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public static RestResult success(Object data) {
        RestResult rr = new RestResult();
        rr.setCode(20000);
        rr.setSuccess(true);
        rr.setMessage("");
        rr.setData(data);
        return rr;
    }

    public static RestResult success() {
        return success("ok");
    }

    public static RestResult error(String message) {
        RestResult rr = new RestResult();
        rr.setSuccess(false);
        rr.setCode(40001);
        rr.setMessage(message);
        return rr;
    }

    public static RestResult error(String code, String message) {
        RestResult rr = new RestResult();
        rr.setSuccess(false);
        rr.setCode(Integer.valueOf(code));
        rr.setMessage(message);
        return rr;
    }

}
